package com.controller;


import com.DTO.FriendDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.entity.Friend;
import com.entity.User;
import com.service.FriendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Set;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author XTC
 * @since 2024-07-10
 */
@RestController
@RequestMapping( "/friend")
@Api(tags = "好友管理器")
@CrossOrigin
public class FriendController {
    @Autowired
    private FriendService friendService;

    @GetMapping("/getAllFriendOf")
    @ApiOperation(value = "获取某用户的所有好友")
    public Set<User> getAllFriendOf(Integer userId){
        return this.friendService.getAllFriendOf(userId);
    }

    @GetMapping("/deleteFriend")
    @ApiOperation(value = "删除好友", notes = "两个id为需删除好友的两个用户的id，userId1主动删除的用户id。返回删除是否成功")
    public boolean deleteFriend(Integer userId1, Integer userId2) {
        return this.friendService.deleteFriend(userId1, userId2);
    }

    @GetMapping("/getAll")
    @ApiOperation(value = "获取好友表中所有数据(测试用)")
    public List<Friend> getAll() {
        return this.friendService.list();
    }

}



